#include "E22_Config.h"
#include "bsp_usart.h"
#include "delay.h"

void E22_RF_Setting_Old(uint16_t Address,uint8_t Channel)
{
	/* Store for Reset & Setting Data */
	uint8_t Soft_Reset[6] = {0};
	/* Get Default Setting from Grand */
	E22_Setting_t E22Setting = {RF433_CONFIG_PACK};
	
	/* Set E22 Into Setting Mode */
	MD0_LOW();
	MD1_HIGH();
	
	/* Old board set mode */
	delay_ms(100);
	
	/* Change Custom Modify Address & Channal */
	E22Setting.Address_L = (Address >> 8) & 0xFF;
	E22Setting.Address_H = (Address) & 0xFF;
	E22Setting.Channal = Channel % E22_CHANNEL_MAX;
    
	/* Send Data for Setting E22 */
	/* Then Waitting Transfer Complete */
	
	send_data_dma_u1(E22Setting.E22_SettingMessage,12);
	
	delay_ms(100);
	
	/* E22 Soft Reset */
	Soft_Reset[0] = 0xC4;
	Soft_Reset[1] = 0xC4;
	Soft_Reset[2] = 0xC4;
	
	/* Send Data for Setting E22 */
	/* Then Waitting Transfer Complete */
	
	send_data_dma_u1(Soft_Reset,3);
	delay_ms(100);
	
	/* Set E22 Into Working Mode */
	MD0_LOW();
	MD1_LOW();
	delay_ms(100);
}

void E22_RF_Setting(uint16_t Address,uint8_t Channel)
{
	MD0_LOW();
	MD1_HIGH();
	delay_ms(100);
	uint8_t send_data[9] = {0xC0,0x00,0x06,0x00,0x0C,0x00,0xE3,0x00,0x12};
	send_data_dma_u1(send_data,9);
	delay_ms(100);
	MD0_LOW();
	MD1_LOW();
}



